﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;

namespace CTEA_INDIA
{
    public partial class User_Registration : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BAL.conn.connectionString = ConfigurationManager.ConnectionStrings["CTEA"].ConnectionString;
            //if (Session["UserID"] != null)
            //{
            //  // Response.Redirect("Default.aspx");
            //}
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            int Login = Convert .ToInt32 ( Session["Login"]);
            string Email = txtEmailId.Text;

            int strVal = BAL.Customers.verifyuser(Email, "", 0);
            if (strVal == -1)
            {

                if (Page.IsValid)
                {
                    string EmailID = txtEmailId.Text;
                    string Password = txtPass.Text;
                    string EncryptedPass = BAL.Encryption.Encript(Password, "&%#@?,:*");
                    string DecryptedPassword = BAL.Encryption.Decrypt(EncryptedPass, "&%#@?,:*");
                    string Name = txtName.Text;
                    string Address = txtAddress.Text;
                    string Location = txtLocation.Text;  
                    string Website=txtWebsite.Text;
               
                  
                    string Conatactno=txtcno.Text;
                    string ContactP_Name = txtContactP_Name.Text;
                    string ContactP_Emailid = txtContactP_EmailID.Text;
                    string ContactP_Mobileno = txtPers_MobileNo.Text;


                    int UserID = BAL.Customers.UserRegistration(EmailID,  EncryptedPass, Name, Address, Location, Website, Conatactno, ContactP_Name, ContactP_Emailid, ContactP_Mobileno);
                    //  BAL.Customers.SendUserDetails(emailid, DecryptedPassword);
                    //    BAL.Customers.RegLink(emailid, IDCustomer.ToString(), password, name);
                    
                    String StrCon = "<div style=\"margin-left:20px;\">" +
                        "<span style=\"font-size: 12px; font-family: 'CENTURY GOTHIC'\">" +
                        "<br>Dear <b>" + Name + "</b>,<br><br>" +
                        "Welcome to <b>CTEA INDIA </b><br><br>" +
                        "We are pleased to welcome you to CTEA INDIA.<br> Thank you for registered with us." +
                        "<br><br>Best Regards,<br>CTEA INDIA Team" +
                        "<br><a href=\"http://www.CTEAINDIA.in\">www.CTEAINDIA.in</a></span><br><br><img src=\"cid:companylogo\"></div>";
                    BAL.Common.SendEmail("", EmailID, "Notification from CTEA India", StrCon);
                    BAL.Customers.SendUserDetails(EmailID, DecryptedPassword);
                    Response.Redirect("Confirmation.aspx");

                }
            }
            else
            {
                errSpan.Visible = true;
                errSpan.InnerHtml = "Your Email ID already exist.";
            }


        }

    }

}
